<template>
	<view class="container">
		<!-- 轮播图部分 -->
		<swiper :indicator-dots="true" :autoplay="true" :interval="5000" :duration="500">
			<swiper-item v-for="item in list" :key="item.id">
				<view class="swiper-item">
					<image :src="'../../static' + item.icon" style="width: 100%; height: 240px;"></image>
				</view>
			</swiper-item>
		</swiper>

		<view class="title">功能列表</view>
		<swiper :indicator-dots="true" :autoplay="false" class="gongneng">
			<swiper-item v-for="i in numberOfPages" :key="i">
				<uni-grid :column="5">
					<uni-grid-item v-for="item in getItemsForPage(i)" :key="item.id">
						<view style="display: flex; flex-direction: column; align-items: center; padding-top: 10px;">
							<image :src="'../../static/' + item.icon" style="width: 80rpx; height: 80rpx;" mode=""></image>
							<view>{{ item.typename }}</view>
						</view>
					</uni-grid-item>
				</uni-grid>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					{ id: 1, icon: "/images/school1.jpg" },
					{ id: 2, icon: "/images/school2.jpg" },
					{ id: 3, icon: "/images/school3.jpg" },
					{ id: 4, icon: "/images/school4.jpg" }
				],
				typelist: [
					{ id: 1, typename: "新闻", icon: "/images/news.png" },
					{ id: 2, typename: "公告", icon: "/images/announcement.gif" },
					{ id: 3, typename: "同学", icon: "/images/classmate.png" },
					{ id: 4, typename: "电话", icon: "/images/telephone.png" },
					{ id: 5, typename: "留言", icon: "/images/leaveword.png" },
					{ id: 6, typename: "教务", icon: "/images/#" },
					{ id: 7, typename: "招生", icon: "/images/#" },
					{ id: 8, typename: "投诉", icon: "/images/#" }
				]
			};
		},
		computed: {
			numberOfPages() {
				return Math.ceil(this.typelist.length / 5);
			}
		},
		methods: {
			getItemsForPage(page) {
				const start = (page - 1) * 5;
				return this.typelist.slice(start, start + 5);
			}
		}
	};
</script>

<style>
	.title{
		padding:  12px 0;
		padding-left: 15px;
		font-size: 16px;
		background-color: #efefef;
	}
	.container {
		padding: 0;
		font-size: 14px;
		line-height: 24px;
	}
	.gongneng{
		height: 120px;
	}
</style>
